import type { UseFetchOptions } from 'nuxt/app'
// import type { FetchError } from 'ofetch'

// interface CustomError {
//   message: string
//   statusCode: number
// }

export function useRequest<T>(
  url: string | (() => string),
  options?: UseFetchOptions<T>
) {
  return useFetch(url, {
    ...options,
    $fetch: useNuxtApp().$request as typeof $fetch
  })
}
